$("#excelFile").on("fileuploaded", function(event, data, previewId, index) { alert("上传成功!"); $("#excelImport").modal("hide"); //后台处理后返回的经纬度坐标json数组, var array = data.response; console.dir(array); //jquery循环取经纬度坐标 $.each(array,function(index,latAndLon){ var lon = latAndLon.lon; var lat = latAndLon.lat; var point = new Point(lon, lat, map.spatialReference); var symbol = new esri.symbol.SimpleMarkerSymbol().setStyle( SimpleMarkerSymbol.STYLE_CIRCLE).setColor( new Color([255,255,0,0.5])); var attr = {"address": "addressName" }; var infoTemplate = new esri.InfoTemplate("标题", "地址 :${address}"); var graphic = new Graphic(point,symbol,attr,infoTemplate); map.graphics.add(graphic); }); });
arcgis中点的定义的两种方法:
1 2
var point = new Point(lon, lat, new SpatialReference({ wkid: 4326 })); var point = new Point(lon, lat, map.spatialReference);
} else { throw new FileUploadException("文件格式不正确"); } } } if (type.equals("station")) { jsonArry = readExcel(fullPath, fileName); } else if (type.equals("line")) { System.out.println("===============:line"); } else if (type.equals("pipeline")) { System.out.println("===============:pipeline"); } else if (type.equals("jdj")) { System.out.println("===============:jdj"); } } return jsonArry; }
// 判断文件类型 public Workbook createWorkBook(InputStream is, String excelFileName) throws IOException { if (excelFileName.toLowerCase().endsWith("xls")) { return new HSSFWorkbook(is); } if (excelFileName.toLowerCase().endsWith("xlsx")) { return new XSSFWorkbook(is); } return null; }
public JSONArray readExcel(String basePath, String fileName) throws FileNotFoundException, IOException { File file = new File(basePath); Workbook book = createWorkBook(new FileInputStream(file), fileName); JSONObject jsonObj = new JSONObject(); JSONArray jsonArry = new JSONArray(); Sheet sheet = book.getSheetAt(0); for (int i = 3; i < sheet.getLastRowNum(); i++) { Row row = sheet.getRow(i); String lon = row.getCell(2).getNumericCellValue() + ""; String lat = row.getCell(3).getNumericCellValue() + ""; jsonObj.put("lat", lat);// 纬度 jsonObj.put("lon", lon);// 经度 jsonArry.add(jsonObj); } System.out.println(jsonArry.toString()); return jsonArry; }